#include <TrackView.h>


/********************************************/
/*              Members                     */
/********************************************/

    /****************************************/
    /*          Constructors                */
    /****************************************/

        TrackView::TrackView()
        {
            m_Projection    =   Matrix4::Perspective(70.0, 1.0, 0.001, 1000.0);
            MainView        =   this;

            m_Center        =   new vec4(0.0,0.0,2.0);
            m_Radius        =   1;
            m_ViewMatrix    =   new Matrix4();

            teta=0.0;
            phi=0.0;
        }

    /****************************************/
    /*          Methods                     */
    /****************************************/



    /****************************************/
    /*          Virtual Methods             */
    /****************************************/

        void TrackView::Display()
        {

        }

        void TrackView::Update()
        {
            float val = 0.1;

            /*if( sf::Keyboard::isKeyPressed(sf::Keyboard::A))
            {
                m_Radius+=val;
            }
            if( sf::Keyboard::isKeyPressed(sf::Keyboard::Z))
            {
                m_Radius-=val;
            }

            if(Application::s_CurrentEvent.type == sf::Event::MouseButtonPressed)
            {
                    xAnchor=Application::s_CurrentEvent.mouseButton.x;
                    yAnchor=Application::s_CurrentEvent.mouseButton.y;
                    buttonPressed=true;
            }

            if(Application::s_CurrentEvent.type == sf::Event::MouseButtonReleased)
            {
                    buttonPressed=false;
                    xAnchor=-1;
                    yAnchor=-1;
            }

            if(Application::s_CurrentEvent.type == sf::Event::MouseMoved)
            {
                if(buttonPressed)
                {
                    int difX = xAnchor-Application::s_CurrentEvent.mouseMove.x;
                    int difY = yAnchor-Application::s_CurrentEvent.mouseMove.y;

                    RotateView(difX, difY);

                    xAnchor=Application::s_CurrentEvent.mouseMove.x;
                    yAnchor=Application::s_CurrentEvent.mouseMove.y;
                }
            }*/

            m_ViewMatrix->Identity();

            m_ViewMatrix->Translate(0.0, 0.0, -m_Radius);
            *m_ViewMatrix   =*m_ViewMatrix*  (Quaternion::Euler(-teta, -phi,0.0 )).RotationMatrix();
            m_ViewMatrix->Translate(m_Center->x, m_Center->y, m_Center->z);

        }

        void TrackView::Zoom(float zoomValue)
        {
            m_Radius    += zoomValue;
        }

        void TrackView::RotateView(int x, int y)
        {
            phi     +=  (float)x*0.005;
            teta    +=  (float)y*0.005;
        }

    /****************************************/
    /*          Operator Overload           */
    /****************************************/





